import java.util.concurrent.atomic.AtomicInteger;

/**
 * projectName: zhouheng
 *
 * @author: smileheng
 * time: 2021/7/29 17:42
 * description:${description}
 */
public class AtomicIntegerTest2 {
    static AtomicInteger a = new AtomicInteger();
    public static void main(String[] args) {
        Thread[] threads = new Thread[5];
        for (int i = 0; i < 5; i++) {
            threads[i] = new Thread(() -> {
                try {
                    for (int j = 0; j < 10; j++) {
                        System.out.println(a.incrementAndGet());
                        Thread.sleep(500);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
            threads[i].start();
        }

    }

}
